package com.yanqu.road.dataHelper.action;

import com.yanqu.road.dataHelper.action.excel.Recharge;
import com.yanqu.road.dataHelper.gameServer.GameServer;
import com.yanqu.road.dataHelper.manager.DataMgr;
import com.yanqu.road.dataHelper.manager.ServerMgr;
import com.yanqu.road.entity.servercenter.ServerInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

//活动期间每日充值
public class RechargeExcel extends actionBase{
    public void go(List<Long> serverList){
        ExecutorService executorService = Executors.newFixedThreadPool(1);
        List<Future> futureList = new ArrayList<>();
        futureList = new ArrayList<>();
        for(Long serverId : serverList){
            if(ServerMgr.getServerInfoList().containsKey(serverId)){
                ServerInfo serverInfo = ServerMgr.getServerInfoList().get(serverId);
                Future future = executorService.submit(new Callable<Boolean>() {
                    @Override
                    public Boolean call() throws Exception {
                        GameServer testGameServer = new GameServer(serverInfo);
                        Recharge recharge = new Recharge(testGameServer);
                        recharge.go();
                        return true;
                    }
                });
                futureList.add(future);
            }
        }
        isResult(futureList);
        DataMgr.makeExcelData2Txt("");
        DataMgr.outText("要删除的用户-");
        System.err.println("``````============================================完成");
    }
}
